package zhongbo.java.air.dictionary.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;
import zhongbo.java.air.dictionary.model.AirAlertZone;
import zhongbo.java.air.dictionary.service.IAirAlertZoneService;

import javax.validation.Valid;

@RestController
@RequestMapping("/airAlertZone")
@Api(tags = "警戒线接口")
public class AirAlertZoneController {

    @Autowired
    private IAirAlertZoneService<AirAlertZone> airAlertZoneService;

//    @GetMapping("/queryByPage")
    @GetMapping("findPage")
    @ApiOperation("分页查询")
    public ResultVo<PageVo<AirAlertZone>> queryByPage(Integer page, Integer pageSize,
              String keyword, String fields,
              String oderByField, Boolean orderByAsc) {
        PageVo<AirAlertZone> airAlertZonePageVo = airAlertZoneService.queryByPage(page, pageSize, keyword, fields, oderByField, orderByAsc);
        return ResultVo.ok(airAlertZonePageVo);
    }

//    @GetMapping("/selectById/{id}")
    @GetMapping("findOne")
    @ApiOperation("根据id查询警戒信息")
    public ResultVo<AirAlertZone> queryById(String entityId) {
        AirAlertZone airAlertZone = airAlertZoneService.queryById(entityId);
        return ResultVo.ok(airAlertZone);
    }

    @PostMapping("/add")
    @ApiOperation("添加警戒信息")
    public ResultVo<AirAlertZone> add(@RequestBody @Valid AirAlertZone airAlertZone) {
        AirAlertZone insert = airAlertZoneService.insert(airAlertZone);
        return ResultVo.ok(insert);
    }

//    @PutMapping("/edit")
    @PostMapping("/edit")
    @ApiOperation("修改飞机信息")
    public ResultVo<AirAlertZone> edit(@RequestBody @Valid AirAlertZone airAlertZone) {
        AirAlertZone update = airAlertZoneService.update(airAlertZone);
        return ResultVo.ok(update);
    }


//    @DeleteMapping("/deleteById/{id}")
    @GetMapping("delete")
    @ApiOperation("根据id删除警戒信息")
    public ResultVo<String> deleteById(String entityId) {
        airAlertZoneService.deleteById(entityId);
        return ResultVo.ok("删除成功");
    }
}
